<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - {$Think.config.INTENDANT_NAME} - by HemaCMS</title>
    <link href="__INTENDANT__/css/admin_style.css" rel="stylesheet" />
    <script src="__COMMON__/jquery.js"></script>
    <script src="__COMMON__/jquery.cookie.js"></script>
    <script src="__COMMON__/layer/layer.js"></script>
    <script src="__INTENDANT__/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
    <link href="__INTENDANT__/css/iteny.css" rel="stylesheet" />
    <style type="text/css">
    tr{border-left: 1px solid #e5e3e3;}
    td{border-right: 1px solid #e5e3e3;}
    </style>
</head>
<body>
<div class="wrap J_check_wrap">
   	<div class="nav">
	    <ul class="cc">
	        <li class="current"><a href="{:U('Site/user')}">用户管理</a></li>
	        <li><a href="{:U('Site/addUser')}">添加账户</a></li>
	    </ul>
	</div>
   <div class="table_list">
   <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <td width="5%" align="center">序号</td>
            <td width="10%" align="center">用户名</td>
            <td width="25%" align="center">所属角色</td>
            <td width="10%"  align="center">最后登录IP</td>
            <td width="10%"  align="center">最后登录时间</td>
            <td width="15%"  align="center">E-mail</td>
            <td width="10%" align="center">备注</td>
            <td width="15%" align="center">管理操作</td>
          </tr>
        </thead>
        <tbody>
        <foreach name="Userlist" item="vo">
          <tr>
            <td width="5%" align="center">{$vo.uid}</td>
            <td width="10%" align="center">{$vo.username}</td>
            <td width="25%" align="center">{$vo.usergroup.0.title}<a class="showrule" data="{$vo.username}" href="{:U('Site/showRole','id=' . $vo["usergroup"][0]["id"] .'&data=' .$vo["usergroup"][0]["title"])}">[点击查看权限]</a></td>
            <td width="10%" align="center">{$vo.last_login_ip}</td>
            <td width="10%" align="center">
            <if condition="$vo['last_login_time'] eq 0">
            该用户还没登陆过
            <else />
            {$vo.last_login_time|date="Y-m-d H:i:s",###}
            </if>
            </td>
            <td width="15%" align="center">{$vo.email}</td>
            <td width="10%" align="center">{$vo.remark}</td>
            <td width="15%" align="center">
            <if condition="$User['username'] eq $vo['username']">
            <font color="#cccccc">修改</font> |
            <font color="#cccccc">删除</font>
            <else />
            <a href="{:U("Site/editUser",array("id"=>$vo[uid]))}">修改</a> |
            <a class="J_ajax_del" datatitle="{$vo.username}" href="{:U('Site/delUser')}" data="{$vo.uid}">删除</a>
            </if>
            </td>
          </tr>
         </foreach>
        </tbody>
      </table>
      <div class="p10">
        <div class="pages"> {$page} </div>
      </div>
   </div>
</div>
<script type="text/javascript">
$(function(){
  $('.J_ajax_del').on('click', function (e) {
    e.preventDefault();
    var title = $(this).attr('datatitle');
    var href = $(this).attr('href');
    var data = $(this).attr('data');
    layer.confirm('是否删除管理员<span style="color:red;">['+title+']</span>', {icon: 3, title:'删除管理员提示'}, function(index){


        layer.close(index);
        $.ajax({
        type: 'post',
        url: href,
        data : {id : data},
        dataType:"json",
        beforeSend: function(){
          layer.load(1);
        },
        success: function(data){
          layer.close(layer.load(1));
          if(!data.status){
            ITENY.alert('提示信息',data.info,2,'5000');

          } else {
            ITENY.alert('提示信息',data.info,1,'5000');
            setTimeout(function(){
                      ITENY.reloadPage(window);
                  },3000);

          }
        },
        error: function(data){
          layer.close(layer.load(1));
          ITENY.alert('提示信息',data.responseText,2,'5000');

        }
      });
    });
  });
	// $('a.showrule').on('click', function (e) {
	// 	e.preventDefault();
	// 	var showruleid = $(this).attr('href');
	// 	var username = $(this).attr('data');
	// 	layer.open({
	// 	    type: 2,
	// 	    title: '查看管理员'+username+'的权限',
	// 	    // shadeClose: true,
	// 	    shade: 0.8,
	// 	    area: ['100%', '100%'],
	// 	    content: showruleid //iframe的url
	// 	});
		// var btn = $(this),
  //       form = btn.parents('form.J_ajaxForm');
  //       if(btn.attr("disabledSubmit")){
	 //        btn.text('请勿重复提交...').prop('disabled', true).addClass('disabled');
	 //        return false;
	 //    }
		// btn.attr("disabledSubmit",true);
  //   	var param = form.serialize();
  //   	$.ajax({
		// 	url: form.attr('action'),
		// 	dataType:'json',
		// 	type:'POST',
		// 	data:param,
		// 	beforeSend: function(){
		// 		layer.load(1);
		// 	},
		// 	success: function(data){
		// 		layer.close(layer.load(1));
		// 		if(!data.status){
		// 			ITENY.alert('提示信息',data.info,1,'5000');

		// 		} else {
		// 			ITENY.alert('提示信息',data.info,2,'5000');
		// 			setTimeout(function(){
		//                 ITENY.reloadPage(window);
		//             },3000);

		// 		}
		// 	},
		// 	error: function(data){
		// 		layer.close(layer.load(1));
		// 		ITENY.alert('提示信息',data.responseText,1,'5000');

		// 	}
		// });
	// });
});
</script>
</body>
</html>